package com.xuehu.cloud.service.impl;

import com.xuehu.cloud.service.IMessageProvider;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author guoweia@cslc.com.cn
 * @create 2020/12/16 13:47
 * @desc
 */
// 定义消息的推送管道
@EnableBinding(Source.class)
@Slf4j
public class MessageProviderImpl implements IMessageProvider {

    /**
     * 消息发送通道
     */
    @Resource
    private MessageChannel output;

    @Override
    public String sendMsg() {
        String uuid = UUID.randomUUID().toString();
        output.send(MessageBuilder.withPayload(uuid).build());
        log.info("*******uuid=" + uuid + "*******");
        return null;
    }
}
